package lol.clann.bukkit.pluginboot.util;

import lol.clann.clannboot.annotation.svc.Service;
import org.bukkit.Chunk;
import org.bukkit.entity.Entity;

import java.util.function.Predicate;

/**
 * @author pyz
 * @date 2018/8/25 下午1:40
 */
@Service(priority = Integer.MAX_VALUE)
public class ChunkUtils {

    /**
     * 从世界中移除满足条件的实体
     *
     * @param chunk
     * @param test
     */
    public void removeEntities(Chunk chunk, Predicate<Entity> test) {
        for (Entity entity : chunk.getEntities()) {
            if (test.test(entity)) {
                entity.remove();
            }
        }
    }

}
